a = input()
ls = []
k = 0
for i in range(len(a)):
	if a[i] == '(' or a[i] == '[' or a[i] == '{' or a[i] == '<':
		ls.append(a[i])
	else:
		if len(ls) != 0:
			ls_last = ls.pop()
			if not(ls_last == '(' and a[i] == ')' or ls_last == '[' and a[i] == ']' or ls_last == '{' and a[i] == '}' or ls_last == '<' and a[i] == '>'):
				print('False')
				k+=1
				break
		else:
		    print('False')
		    k+=1
		    break
if len(ls) == 0 and k != 1:
	print('True')
elif len(ls) != 0 and k!= 1: 
    print('False')
